//
//  GlobalDefine.h
//  BMS
//
//  Created by 颜魏 on 2021/4/16.
//

#ifndef GlobalDefine_h
#define GlobalDefine_h

//循环引用处理宏
#define WeakSelf  __weak __typeof(&*self)weakSelf = self;

//系统检测
#define IPHONE_X \
({BOOL isPhoneX = NO;\
if (@available(iOS 11.0, *)) {\
isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0;\
}\
(isPhoneX);})

//色值宏
#define RGB16(rgbValue)\
\
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 \
alpha:1.0]
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
#define SUBJECT_COLOR RGBCOLOR(125, 177, 80)

//常用宏
#define kWidth  ([[UIScreen mainScreen] bounds].size.width)
#define kHeight ([[UIScreen mainScreen] bounds].size.height)
#define StatusBarHeight UIApplication.sharedApplication.statusBarFrame.size.height
#define IphoneX StatusBarHeight > 20

//Notification Key
#define kBTPoweredOff      @"kBTPoweredOff"         //蓝牙关闭
#define kBTSearchDevices   @"kBTSearchDevices"      //搜索到设备
#define kBTConnectionSucceed    @"kBTConnectionSucceed" //蓝牙连接成功
#define kBTDisconnect      @"kBTDisconnect"         //连接断开
#define kBTFailToConnect   @"kBTFailToConnect"      //连接失败
#define kBTDidReciveData   @"kBTDidReciveData"      //接收到数据
#define kBTGetBatteryLevel  @"kBTGetBatteryLevel"      //获取到电池电量
#define kBTSearchDevicesName @"kBTSearchDevicesName"
#define kBTUpgrading    @"kBTUpgrading"
#define kBTUpgradeFail  @"kBTUpgradeFail"
#define kTXRXUpdate     @"kTXRXUpdate"
#define kBTBluGroupChanged @"kBTBluGroupChanged"
#define BatteryGroupBluList @"BatteryGroupBluList"
#define kBTAddViewDismiss @"kBTAddViewDismiss"

//UserDefaults Key
#define PlaySoundState      @"PlaySoundState"       //播放警告声状态

#endif /* GlobalDefine_h */
